/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.xj.marqueeview.sample;

import ohos.aafwk.ability.AbilitySlice;
import org.junit.Test;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * 单元测试类
 *
 * @author:Hexy
 * @since 2021-03-24
 */
public class ExampleOhosTest extends AbilitySlice{

    /**
     * 从上进入，从下退出
     */
    @Test
    public void startUpAnimator() {
        try {
            Class mainAbilitySlice = Class.forName("com.xj.marqueeview.sample.slice.MainAbilitySlice");
            Method releaseBitmapMethod = mainAbilitySlice.getMethod("startUpAnimator");
            Object object = mainAbilitySlice.getConstructor().newInstance();
            releaseBitmapMethod.invoke(object);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }

    /**
     * 从下进入，从上退出
     */
    @Test
    public void startDownAnimator() {
        try {
            Class mainAbilitySlice = Class.forName("com.xj.marqueeview.sample.slice.MainAbilitySlice");
            Method releaseBitmapMethod = mainAbilitySlice.getMethod("startDownAnimator");
            Object object = mainAbilitySlice.getConstructor().newInstance();
            releaseBitmapMethod.invoke(object);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }

    /**
     * 从左进入，从右退出
     */
    @Test
    public void startLeftAnimator() {
        try {
            Class mainAbilitySlice = Class.forName("com.xj.marqueeview.sample.slice.MainAbilitySlice");
            Method releaseBitmapMethod = mainAbilitySlice.getMethod("startLeftAnimator");
            Object object = mainAbilitySlice.getConstructor().newInstance();
            releaseBitmapMethod.invoke(object);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }

    /**
     * 从右进入，从左退出
     */
    @Test
    public void startRightAnimator() {
        try {
            Class mainAbilitySlice = Class.forName("com.xj.marqueeview.sample.slice.MainAbilitySlice");
            Method releaseBitmapMethod = mainAbilitySlice.getMethod("startRightAnimator");
            Object object = mainAbilitySlice.getConstructor().newInstance();
            releaseBitmapMethod.invoke(object);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }

}